﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;


public partial class Pages_InCacNghiepVuNhanHang_Printing : webapp4U.UI.BasePage
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {     
        

        ControlReportViewer1.ReportViewer.Report = CreateReport();
    }
    DevExpress.XtraReports.UI.XtraReport CreateReport()
    {
        XtraReportInNhanHangTuNCC tableReport = new XtraReportInNhanHangTuNCC();
        if (Session["Sitecode"] != null)
        {
            string VchNo = "";
            if (Request.QueryString["VchNo"] != null)
            {
                VchNo = Request.QueryString["VchNo"].ToString();
            }
            dt = new ClassExecute.ClassExecute();
            DataSet ds = new DataSet();

            ds = dt.Get_Data_DataSet(str, ref error, "ls_getVoucher4Print", CommandType.StoredProcedure,
                new SqlParameter("@VchNo", VchNo),
                new SqlParameter("@siteCode", Session["Sitecode"].ToString()));
            
            string SiteName ="";
            DataTable data = dt.Get_Data_DataTable(str, ref error, "ls_getStoreName", CommandType.StoredProcedure, new SqlParameter("@siteCode", Session["Sitecode"].ToString()));
            if(data.Rows.Count>0)
            {
                SiteName = data.Rows[0]["sitename"].ToString();
            }
            string strNgayHoaDon = "";
            if(Session["NgayHoaDonNhanHang"]!=null)
                strNgayHoaDon = Session["NgayHoaDonNhanHang"].ToString();
            tableReport.SetReportParameter(ds, SiteName, VchNo, strNgayHoaDon);            
        }
        return tableReport;
    }
}
